package com.juhe.transmission;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FileUtils {

	public void listAllFile(File dir, List<String> allFileList, List<String> allDirList){
		
		if(dir == null || !(dir.isDirectory())){
			return;
		}
		File[] fileArray = dir.listFiles();
		
		for(int i = 0; i < fileArray.length; i ++){
			if(fileArray[i].isFile()){
				allFileList.add(fileArray[i].getName());
			}else{
				allDirList.add(fileArray[i].getName());
			}
		}
	}
	public void listAllFile(String dir, List<String> allFileList, List<String> allDirList){
		File dirFile = new File(dir);
		this.listAllFile(dirFile, allFileList, allDirList);
	}
	
	
	public static void main(String[] args) {
		List<String> allFileList = new ArrayList<String>();
		List<String> allDirList = new ArrayList<String>();
		String fileDir = "I:\\software\\";
		File file = new File(fileDir);
		new FileUtils().listAllFile(file, allFileList, allDirList);
		for(int i = 0; i < allFileList.size(); i ++){
			System.out.println(fileDir + allFileList.get(i));
		}
		System.out.println();
		for(int i = 0; i < allDirList.size(); i ++){
			System.out.println(fileDir + allDirList.get(i));
		}
		
	}
	
	
}
